import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    

    AutoImport({
      resolvers: [
        // 自动导入element-plus组件
          ElementPlusResolver(),
          // 自动导入图标组件
          IconsResolver({
              prefix: 'Icon'
          })
      ],
  }),

    
    Components({
      dts: true,//允许去文件夹找
      dirs: ['src/components','src/views'], // 按需加载的文件夹
      resolvers: [
        // 自动导入element-plus组件
          ElementPlusResolver(),
          // 自动导入图标组件
          IconsResolver({
              enabledCollections: ['ep']
          })
      ],
     

    }),
    Icons({
      autoInstall: true,
  }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
